﻿using System;
using DapperExtensions.Mapper;
using Newtonsoft.Json;

namespace ZilLion.Service.TaskPlatform.Domain.Entity
{
    public class TaskConmmandEntity
    {
        /// <summary>
        ///     CommandId
        /// </summary>
        [JsonProperty("commandId")]
        public string CommandId { get; set; }

        /// <summary>
        ///     命令json
        /// </summary>
        [JsonProperty("commandContent")]
        public string CommandContent { get; set; } = string.Empty;

        /// <summary>
        ///     命令名，参考代码枚举
        /// </summary>
        [JsonProperty("commandname")]
        public string Commandname { get; set; }

        /// <summary>
        ///     命令执行状态，参考代码枚举
        /// </summary>
        [JsonProperty("commandstate")]
        public short Commandstate { get; set; }

        /// <summary>
        ///     任务id
        /// </summary>
        [JsonProperty("taskid")]
        public string Taskid { get; set; }

        /// <summary>
        ///     节点id
        /// </summary>
        [JsonProperty("nodeId")]
        public string NodeId { get; set; }

        /// <summary>
        ///     命令创建时间
        /// </summary>
        [JsonProperty("commandUpdateTime")]
        public DateTime CommandUpdateTime { get; set; }
    }

    public sealed class TaskConmmandEntityMapper : ClassMapper<TaskConmmandEntity>
    {
        public TaskConmmandEntityMapper()
        {
            Table("task_command");
            Map(f => f.CommandId).Key(KeyType.Assigned).Column("commandid");

            Map(f => f.CommandContent).Column("commandcontent");
            Map(f => f.Commandname).Column("commandname");
            Map(f => f.Commandstate).Column("commandstate");

            Map(f => f.Taskid).Column("taskid");
            Map(f => f.NodeId).Column("nodeid");
            Map(f => f.CommandUpdateTime).Column("commandupdatetime");
        }
    }
}